<template>
	<view class="bgtmert">
		<view class="pd mt50 row">
			<image :src="resdata.avatar" class="yj usericonsder"></image>
			<view class="col ml30">
				<view class="fz40 cf mt10">
					<text class="cz">{{resdata.remark}}</text>
					<text class="cz ml30 f_b jhbnhher fz24" v-if="type==1">超级管理员</text>
					<text class="cz ml30 f_b jhbnhher fz24 ab" v-if="type==2">管理员</text>
					<text class="cz ml30 f_b jhbnhher fz24 ac" v-if="type==3">普通群员</text>
				</view>
				<view class="cf mt20 fz28">
					账号：{{resdata.phone}}
				</view>
			</view>
		</view>
		<uni-list class="mt90">
			<uni-list-item title="历史行程" note=""></uni-list-item>
		</uni-list>

		<view class="mt80 pd" v-if="type==0">
			<view class="fz28 z9">
				驾驶管理权限
			</view>
			<view class="kjnnjhhxeet mt20">
				<view class="cen">
					<view class="kjnmkjhndrt">
						<image src="../../../static/img/dfdsfa.png" class="kjnnhghgce cz" mode="widthFix"></image>
					</view>
					<view class="cf fz26">
						副钥匙分发
					</view>
				</view>
				<view class="cen">
					<view class="kjnmkjhndrt">
						<image src="../../../static/img/dfdsfb.png" class="kjnnhghgce cz" mode="widthFix"></image>
					</view>
					<view class="cf fz26">
						副钥匙收回
					</view>
				</view>
			</view>
		</view>

		<view class="mt80 pd" v-if="type==0">
			<view class="fz28 z9">
				调度管理权限
			</view>
			<view class="kjnnjhhxeet mt20" >
				<view class="cen">
					<view class="kjnmkjhndrt">
						<image src="../../../static/img/dfdsfc.png" class="kjnnhghgce cz ac" mode="widthFix"></image>
					</view>
					<view class="cf fz26">
						派车管理
					</view>
				</view>
				<view class="cen">
					<view class="kjnmkjhndrt">
						<image src="../../../static/img/dfdsfd.png" class="kjnnhghgce cz ad" mode="widthFix"></image>
					</view>
					<view class="cf fz26">
						审批管理
					</view>
				</view>
			</view>
		</view>


		<view class="mt90" v-if="type==1">
			<view class="cf fz30 pd ">
				副钥匙车辆
			</view>
			<view class="mt50 pd">
				<view class="uuhnnxeerty yj f_b cz" v-for="sd in resdata.key_cars">
					<image :src="sd.image" class="yj  "></image>
				</view>
				<navigator url="CreateGroup?type=1" class="uuhnnxeerty f_b yj cz">
					<image src="../../../static/img/sdfdfa.png" mode="widthFix" class="kjnmkrtxere cz"></image>
				</navigator>
				<view class="uuhnnxeerty f_b yj cz">
					<image src="../../../static/img/sdfdfb.png" mode="widthFix" class="kjnmkrtxere cz"></image>
				</view>
			</view>
		</view>


	</view>
</template>
<script>
	export default {
		data() {
			return {
				type: 1, //0 管理员   1 普通用户
				gid:'',
				uid:'',
				resdata:{},
				identity:1
			}
		},
		components: {},
		methods: {
			async dengljse() {
				let cs = {}
				cs.gid = this.gid
				cs.id = this.uid
				let values=await this.get('/api/group_user/'+cs.id+'/user')
				console.log(values)
				this.resdata = values.data
				this.type = values.data.level
				this.type = values.data.identity
			},
			async relieve(){
				var params=""
				var jiechu=await this.get("/api/group_user/"+this.uid+"/remove",params,"PUT")
				this.type=3
				console.log("解除管理员",jiechu)
			},
			async del(){
				var params=""
				var shanchu=await this.get("/api/group_user/"+this.uid+"/delete",params,"DELETE")				
				console.log("删除成员",shanchu)
			}
		},
		onNavigationBarButtonTap(e) {
			var that=this
			let hgbhjhsd = ['编辑', '解除管理员', '删除该成员'],
			th=this
			if (this.type == 3) {
				hgbhjhsd[1] = '设为管理员'
			}
			uni.showActionSheet({
				itemList:hgbhjhsd,
				success: (e) => {
					if (e.tapIndex == 0) {
						uni.navigateTo({
							url: 'Compile?uid='+that.uid
						})
					} else if (e.tapIndex == 1) {
						if(th.type==2){
							uni.showModal({
								title: '',
								content: '您确定要解除'+th.resdata.remark+'的管理员身份吗？',
								success() {
									if (res.confirm) {
										console.log('用户点击确定');
										th.relieve()
									} else if (res.cancel) {
										console.log('用户点击取消');
									}									
								}
							})
						} else if(th.type==3){
							th.type=2
							uni.showToast({
								title:'设为管理员成功'
							})
						}
						
					} else if (e.tapIndex == 2) {
						uni.showModal({
							title: '',
							content: '您确定从群组里删除“'+th.resdata.remark+'”吗？',
							confirmColor: '#FC5A5A',
							confirmText: '删除',
							success() {
								if (res.confirm) {
									console.log('用户点击确定');
									th.del()
								} else if (res.cancel) {
									console.log('用户点击取消');
								}	
							}
						})
					}
				}
			})
		},
		onLoad(options){
			this.uid = options.id
			this.gid = options.gid
			this.dengljse() 
		},
		onShow() {
			this.dengljse()
		},
		mounted() {
			this.type = Math.floor(Math.random() * 2)
		}
	}
</script>
<style scoped>

</style>
